﻿using System;
using System.IO;
using System.Runtime;

namespace OOP
{
    /// <summary>
    /// 掷色子游戏
    /// </summary>
    public class Dice
    {


        public Dice(int limit = 7)
        {

            sumLimit = limit; //阈值
        }
        public void Play(List<Die> dies)
        {
            dieSum = 0;
            foreach (var item in dies)
            {
                dieSum += item.Rolls();
            }
        }
        public bool GetResult()
        {
            return (dieSum>sumLimit);
        }
 
        public int GetDieSum()
        {
            return dieSum;    
        }
        //
  
        private int dieSum; //点数和
        private int sumLimit;
    }
    ///
    /// /// 定义一个筛子类
    public class Die
    {
        /// <summary>
        /// 构造函数，实列化类并生成对象
        /// Constructor, Class Initialization 
        /// </summary>
        public Die()
        {
            Console.WriteLine($"I am a Dice Object, My Class is {this.GetType()}");
        }

       
        /// <summary>
        /// 方法
        /// 1-6 随机返回一个数值
        /// </summary>
        /// <returns>返回点数(return face value)</returns>
        public int Rolls()
        {
            var rand = new Random();
            return rand.Next(1, 6);
        }

        
    }
}
